<template>
    <div>
        <div class="banner">
            <img src="@/assets/img/introduce/banner_a@2x.png" alt="banner">
        </div>
        <el-row class="content">
            <el-row class="contentInner">
                <NavStitle :routes="routes" :links="links"/>
                <el-row class="routerView">
                    <el-row class="left">
                        <router-view/>
                    </el-row>
                    <el-row class="right">
                        <div class="searchBar">
                            <input type="text" placeholder="输入关键字"/>
                            <img src="@/assets/img/news/search.png" alt="search">
                        </div>
                        <p class="fastnav">快速导航</p>
                        <router-link 
                            class="link" 
                            v-for="(item,i) in routes"
                            :to="links[i]"
                            tag="p"
                            :key="item">{{item}}
                            </router-link>
                        <div class="timeNav">发表时间</div>
                        <p 
                            class="timeItem"
                            :class="timeIdx===i?'active':''" 
                            :key="item"
                            @click="timeIdx = i"
                            v-for="(item,i) in timeItems">{{item}}</p> 
                    </el-row>
                </el-row>
            </el-row>
        </el-row>
    </div>
</template>

<script>
import NavStitle from '@/components/navStitle';
import request from '@/request.js';
export default {
    components:{NavStitle},
    data(){
        return {
            links:[
                '/news/events',
                '/news/information/0',
                '/news/information/1',
            ],
            timeItems:[],
            timeIdx:0
        }
    },
    computed:{
        routes(){
            return this.$t("news.nav");
        }
    },
    mounted(){
       this.createTimes();
    },
    methods:{
        createTimes(){
            const arr =[];
            const now = new Date();
            let month = now.getMonth()+1;
            let year = now.getFullYear();
            const len =7;
            for (let index = 0; index < len; index++) {
                const islastYear = (month - index)<1;
                const useMonth = islastYear?13-index:month - index;
                const useYear = islastYear?year-1:year
                const str = `${useYear}年${useMonth}月`;
                arr.push(str);
            }
            this.timeItems = arr;
        }
    }
}
</script>

<style lang="less" scoped>
.banner {
    height: 280px;
    background-color: pink;
    img {
        height: 280px;
        width: 100%;
    }
}
.content {
    margin-top: 37px;
    .contentInner {
        width:1280px;
        margin: 0 auto;
        .routerView {
            padding-top: 40px;
            display: flex;
            .left {
                flex: 1;
            }
            .right {
                margin-left: 40px;
                flex: 0 0 380px;
                text-align: left;
                .searchBar {
                    height: 50px;
                    background-color: #E9EEF2;
                    border:1px solid rgba(233,238,242,1);
                    border-radius:25px;
                    display: flex;
                    align-items: center;
                    padding: 0 25px;
                    margin-bottom: 40px;
                    &>input {
                        font-size: 12px;
                        width: 100%;
                        height: 21px;
                        background-color: #E9EEF2;
                        border: none;
                        outline: none;
                    }
                    &>img {
                        width: 21px;
                        height: 21px;
                        flex: 0 0 21px;
                    }
                }
                .fastnav {
                    margin-bottom: 40px;
                    font-size:22px;
                    font-weight:400;
                    color:rgba(102,102,102,1);
                    line-height:24px;
                }
                .link {
                    margin-bottom: 24px;
                    font-size:14px;
                    font-weight:400;
                    color:rgba(102,102,102,1);
                    line-height:24px;
                    cursor: pointer;
                }
                .router-link-active {
                    color: #D73A42;
                    position: relative;
                    &::before {
                        content:"";
                        width: 0;
                        height: 0;
                        position: absolute;
                        left: -14px;
                        top: 7px;
                        border:5px solid transparent;
                        border-left-color: #D73A42;
                    }
                }
                .timeNav {
                    margin: 36px 0;
                }
                .timeItem {
                    font-size:12px;
                    font-weight:400;
                    color: #999999;
                    line-height:1;
                    margin-bottom: 16px;
                    cursor: pointer;
                }
                .active {
                    color: #333;
                }
            }
        }
    }
}
</style>